################################################
#                                              #
#   SYSGEM Enterprise Manager 2.3 build 5490   #
#   Copyright (C) 2009 SYSGEM AG               #
#                                              #
#   Contents   : Tasks                         #
#                                              #
#   Created by : SWiM                          #
#   Timestamp  : 2013-02-22 15:56:20           #
#                                              #
################################################
#
100 Reorder custom displays
102 Translations
#
101 Created 2013-02-20 07:32:20 by SWiM
#
#
124 /*****************************/
124 /*                           */
124 /* CL Program                */
124 /*                           */
124 /*****************************/
124 
#
#
120 #++++++++++++++++++++++++++++++++++
120 #                                 |
120 #   Windows NT script (PERL).     |
120 #                                 |
120 #++++++++++++++++++++++++++++++++++
120 #
120 #
120 
120 use strict;
120 
120 my $infile  = $INPUT_IN;
120 my $outfile = $INPUT_OU;
120 
120 my @indata  = ();
120 my @outdata = ();
120 
120 my %Displays = ();
120 
120 my $inseq  = 0;
120 my $outseq = 0;
120 my $dspseq = 0;
120 
120 my $display = "";
120 
120 
120 if ( open(IN, "< $infile") )
120 {
120     @indata = <IN>;
120 
120     close(IN);
120 }
120 else
120 {
120     print "Can't open $infile\n";
120 }
120 
120 open(OUT, "> $outfile");
120 
120 #
120 #  1st pass: parse input & save each display into a hash
120 #
120 my $count = @indata;
120 
120 print "starting to re-order custom displays ($count lines)\n";
120 print "file: ($infile)\n";
120 
120 foreach my $line (@indata)
120 {
120     #
120     #  start of display section
120     #
120     if (substr($line, 0, 4) eq "101 ")
120     {
120         $display = substr($line, 4);
120         chomp $display;
120 
120         push(@outdata, "<Substitute-Display>");
120 
120         $dspseq = 0;
120         $Displays{$display}{$dspseq} = $line;
120         $dspseq++;
120 
120         next;
120     }
120 
120     #
120     #  end of display section
120     #
120     if (substr($line, 0, 3) eq "\@D\@")
120     {
120         #
120         #  end of this display 
120         #
120         $Displays{$display}{$dspseq} = $line;
120         $display = "";
120 
120         next;
120     }
120 
120     if ($display eq "")
120     {
120         #
120         #  not in context of a display - just copy to output stream
120         #
120         push(@outdata, $line);
120         next;
120     }
120     else
120     {
120         #
120         #  save the display info
120         #
120         $Displays{$display}{$dspseq} = $line;
120         $dspseq++;
120     }
120 }
120 
120 
120 #
120 #  2nd pass: reconstitute output with re-ordered displays
120 #
120 my @orderedDisplays = sort keys %Displays;
120 
120 my $ordseq = 0;
120 
120 my @output = ();
120 
120 foreach my $line (@outdata)
120 {
120     if ($line eq "<Substitute-Display>")
120     {
120         substituteNextDisplay();
120     }
120     else
120     {
120         push(@output, $line);
120     }
120 }
120 
120 
120 #
120 #  3rd pass: write the outputfile
120 #
120 
120 foreach my $line (@output)
120 {
120     print OUT $line;
120 }
120 
120 close(OUT);
120 
120 print "\n**************\n";
120 print "Custom displays re-ordered\n";
120 
120 
120 sub substituteNextDisplay
120 {
120     my $disp = $orderedDisplays[$ordseq];
120 
120     $ordseq++;
120 
120     my $seq = 0;
120 
120     while (exists($Displays{$disp}{$seq}))
120     {
120         push(@output, $Displays{$disp}{$seq});
120         $seq++;
120     }
120 }
#
#
121 #!/bin/ksh -ph
121 #
121 #{{SHELL_IRIX  #!/usr/bin/ksh
121 #{{SHELL_LINUX #!/bin/sh
121 #
121 #+++++++++++++++++++++++++++
121 #                          |
121 #   UNIX Shell script.     |
121 #                          |
121 #+++++++++++++++++++++++++++
121 #
121 #
121 #
#
122 $!+++++++++++++++++++++++++++++
122 $!                            |
122 $!  VMS command file (DCL).   |
122 $!                            |
122 $!+++++++++++++++++++++++++++++
122 $!
122 $!
#
145 
144 
141 
146 
142 
143 
130 XX
131 ~f~oReorder Displays in alphabetic order in Custom Display Definitions file
132 
133 4
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 3
157 1
&
#
130 XY
131 
132 
133 4
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 1
157 1
&
#
130 IN
131 Custom display file
132 
133 14
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 3
157 1
&
#
130 OU
131 Output File
132 
133 22
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 3
157 1
&
#
@
#
100 Reorder include files
102 Translations
#
101 Created 2013-02-20 07:32:20 by SWiM
#
#
124 /*****************************/
124 /*                           */
124 /* CL Program                */
124 /*                           */
124 /*****************************/
124 
#
#
120 #++++++++++++++++++++++++++++++++++
120 #                                 |
120 #   Windows NT script (PERL).     |
120 #                                 |
120 #++++++++++++++++++++++++++++++++++
120 #
120 #
120 
120 use strict;
120 
120 my $infile  = $INPUT_IN;
120 my $outfile = $INPUT_OU;
120 
120 my @indata  = ();
120 my @outdata = ();
120 
120 my %Displays = ();
120 
120 my $inseq  = 0;
120 my $outseq = 0;
120 my $dspseq = 0;
120 
120 my $display = "";
120 
120 
120 if ( open(IN, "< $infile") )
120 {
120     @indata = <IN>;
120 
120     close(IN);
120 }
120 else
120 {
120     print "Can't open $infile\n";
120 }
120 
120 open(OUT, "> $outfile");
120 
120 #
120 #  1st pass: parse input & save each display into a hash
120 #
120 my $count = @indata;
120 
120 print "starting to re-order include files ($count lines)\n";
120 print "file: ($infile)\n";
120 
120 foreach my $line (@indata)
120 {
120     #
120     #  start of file section
120     #
120     if (substr($line, 0, 4) eq "101 ")
120     {
120         $display = substr($line, 4);
120         chomp $display;
120 
120         push(@outdata, "<Substitute-Display>");
120 
120         $dspseq = 0;
120         $Displays{$display}{$dspseq} = $line;
120         $dspseq++;
120 
120         next;
120     }
120 
120     #
120     #  end of file section
120     #
120     if (substr($line, 0, 1) eq "\@")
120     {
120         #
120         #  end of this display 
120         #
120         $Displays{$display}{$dspseq} = $line;
120         $display = "";
120 
120         next;
120     }
120 
120     if ($display eq "")
120     {
120         #
120         #  not in context of an include file - just copy to output stream
120         #
120         push(@outdata, $line);
120         next;
120     }
120     else
120     {
120         #
120         #  save the include file info
120         #
120         $Displays{$display}{$dspseq} = $line;
120         $dspseq++;
120     }
120 }
120 
120 
120 #
120 #  2nd pass: reconstitute output with re-ordered include files
120 #
120 my @orderedDisplays = sort keys %Displays;
120 
120 my $ordseq = 0;
120 
120 my @output = ();
120 
120 foreach my $line (@outdata)
120 {
120     if ($line eq "<Substitute-Display>")
120     {
120         substituteNextDisplay();
120     }
120     else
120     {
120         push(@output, $line);
120     }
120 }
120 
120 
120 #
120 #  3rd pass: write the outputfile
120 #
120 
120 foreach my $line (@output)
120 {
120     print OUT $line;
120 }
120 
120 close(OUT);
120 
120 
120 print "\n**************\n";
120 print "Include files re-ordered\n";
120 
120 
120 sub substituteNextDisplay
120 {
120     my $disp = $orderedDisplays[$ordseq];
120 
120     $ordseq++;
120 
120     my $seq = 0;
120 
120     while (exists($Displays{$disp}{$seq}))
120     {
120         push(@output, $Displays{$disp}{$seq});
120         $seq++;
120     }
120 }
#
#
121 #!/bin/ksh -ph
121 #
121 #{{SHELL_IRIX  #!/usr/bin/ksh
121 #{{SHELL_LINUX #!/bin/sh
121 #
121 #+++++++++++++++++++++++++++
121 #                          |
121 #   UNIX Shell script.     |
121 #                          |
121 #+++++++++++++++++++++++++++
121 #
121 #
121 #
#
122 $!+++++++++++++++++++++++++++++
122 $!                            |
122 $!  VMS command file (DCL).   |
122 $!                            |
122 $!+++++++++++++++++++++++++++++
122 $!
122 $!
#
145 
144 
141 
146 
142 
143 
130 XX
131 ~f~oReorder include files in alphabetical order in File Definitions file
132 
133 4
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 4
157 1
&
#
130 XY
131 
132 
133 4
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 4
157 1
&
#
130 IN
131 File Definition file
132 
133 14
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 4
157 1
&
#
130 OU
131 Output File
132 
133 22
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 4
157 1
&
#
@
#
100 Translate custom displays
102 Translations
#
101 Created 2013-02-20 07:32:20 by SWiM
#
#
124 /*****************************/
124 /*                           */
124 /* CL Program                */
124 /*                           */
124 /*****************************/
124 
#
#
120 #++++++++++++++++++++++++++++++++++
120 #                                 |
120 #   Windows NT script (PERL).     |
120 #                                 |
120 #++++++++++++++++++++++++++++++++++
120 #
120 #
120 
120 use strict;
120 
120 use Sysgem;
120 
120 use Time::localtime;
120 
120 #
120 #   Create a timestamp.
120 #
120 my $tm      = localtime;
120 my $TimeNow = sprintf("%04d-%02d-%02d %02d:%02d:%02d",
120                       ($tm->year) + 1900,
120                       ($tm->mon)  + 1,
120                       ($tm->mday),
120                       $tm->hour,
120                       $tm->min,
120                       $tm->sec);
120 
120 my $FileExt = sprintf("_%04d-%02d-%02d_%02d-%02d-%02d.txt",
120                       ($tm->year) + 1900,
120                       ($tm->mon)  + 1,
120                       ($tm->mday),
120                       $tm->hour,
120                       $tm->min,
120                       $tm->sec);
120 
120 my $infile   = $INPUT_IN;
120 my $outfile  = $INPUT_OU;
120 my $tranfile = $INPUT_TF;
120 my $rptfile  = $INPUT_RF;
120 
120 $rptfile =~ s/.txt/$FileExt/;
120 
120 my @indata   = ();
120 my @outdata  = ();
120 my @trandata = ();
120 
120 my $inseq    = 0;
120 my $transeq  = 0;
120 
120 my $TotalChanges = 0;
120 my $TotalErrors  = 0;
120 
120 my %lineChanged = ();
120 
120 print "\n___________________\n";
120 print "Initialising ... \n\n";
120 
120 #
120 #  input file 
120 #
120 if ( open(IN, "< $infile") )
120 {
120     @indata = <IN>;
120 
120     close(IN);
120 }
120 else
120 {
120     print "Can't open input definitions file: $infile\n";
120     exit;
120 }
120 
120 
120 #
120 #  and make an exact copy as the initial version of the output file
120 #
120 if ( open(IN, "< $infile") )
120 {
120     @outdata = <IN>;
120 
120     close(IN);
120 }
120 else
120 {
120     print "Can't open input definitions file: $infile\n";
120     exit;
120 }
120 
120 #
120 #  transalation file 
120 #
120 if ( open(TRAN, "< $tranfile") )
120 {
120     @trandata = <TRAN>;
120 
120     close(TRAN);
120 }
120 else
120 {
120     print "Can't open translation file: $tranfile\n";
120     exit;
120 }
120 
120 #
120 #  output file 
120 #
120 if ( ! open(OUT, "> $outfile") )
120 {
120     print "Can't open translated output file: $outfile\n";
120     exit;
120 }
120 
120 #
120 #  report file 
120 #
120 if ( ! open(RPT, "> $rptfile") )
120 {
120     print "Can't open report file: $rptfile\n";
120     exit;
120 }
120 
120 print RPT "Translation Report - $TimeNow\n";
120 print RPT "________________________________________\n\n";
120 
120 print RPT "Input File  ........: $infile\n";
120 print RPT "Output File ........: $outfile\n";
120 print RPT "Translation File ...: $tranfile\n\n";
120 
120 
120 print RPT "Changed Lines: \n\n";
120 
120 print RPT "Line    : \tNew Text \n\n";
120 
120 #
120 #  For each line in the translation file - scan the complete custom file and make global replacements
120 #
120 my $count = @indata;
120 
120 print "Reading input file ($count lines)\n";
120 print "file: ($infile)\n\n";
120 
120 $count = @trandata;
120 
120 print "Reading translation file ($count lines)\n";
120 print "file: ($tranfile)\n\n";
120 
120 print "___________________\n";
120 print "starting to translate ...\n\n";
120 
120 foreach my $line (@trandata)
120 {
120     $transeq++;
120 
120     chomp $line;
120 
120     $line = Sysgem::TrimLeft($line);
120 
120     my @parts = split("\t", $line);
120 
120     if (substr($line, 0, 1) eq "#" || $line eq "")
120     {
120         next;
120     }
120 
120     my $sect = @parts;
120 
120     if ($sect != 3)
120     {
120         print "\@{{B Invalid Translation file - line: $transeq\n";
120         print "\@{{T Invalid Translation file - line: $transeq\n";
120         print "\@{{T \n";
120 
120         $sect--;
120 
120         print "\@{{T Number of tabs in line = $sect\n";
120         print "\@{{T \n";
120         print "\@{{T The line must have exactly two tabs.\n";
120         print "\@{{T \n";
120         print "\@{{T (line code  <tab>  original text  <tab>  translated text)\n";
120         print "\@{{T \n";
120         print "\@{{T $line \n";
120         print "\@{{T \n";
120         print "\@{{DE\n";
120 
120         print "*** ERROR ***";
120         print "$line\n";
120 
120         exit;
120     }
120 
120     my $len = length($parts[0]);
120     if ($len != 4)
120     {
120         print "\@{{B Invalid Translation file - line: $transeq\n";
120         print "\@{{T Invalid Translation file - line: $transeq\n";
120         print "\@{{T \n";
120 
120         $sect--;
120 
120         print "\@{{T Number of character in first field (line code) = $len\n";
120         print "\@{{T \n";
120         print "\@{{T The field must have exactly four characters - e.g. \"101 \"\n";
120         print "\@{{T \n";
120         print "\@{{T $line \n";
120         print "\@{{T \n";
120         print "\@{{DE\n";
120 
120         print "*** ERROR ***";
120         print "$line\n";
120 
120         exit;
120 
120     }
120 
120     #
120     #  escape special characters
120     #
120     $parts[1] =~ s/\\/\\\\/g;
120     $parts[1] =~ s/\"/\\\"/g;
120     $parts[1] =~ s/\@/\\\@/g;
120     $parts[1] =~ s/\$/\\\$/g;
120     $parts[1] =~ s/\%/\\\%/g;
120 
120     $inseq  = 0;
120     my $found = 0;
120 
120     foreach my $inLine (@indata)
120     {
120 
120         if (substr($inLine, 0, 4) eq $parts[0])
120         {
120             # 
120             # we have have a match
120             #
120             if ($inLine =~ m/$parts[1]/)
120             {
120                  #
120                  #  substitute the string
120                  #
120                  $found++;
120 
120                  $inLine =~ s/$parts[1]/$parts[2]/;
120                  $outdata[$inseq] = $inLine;
120 
120                  #
120                  #  increment total number of changes made
120                  #
120                  $TotalChanges++;
120 
120                  #
120                  #  note which line changed
120                  #
120                  if (exists($lineChanged{$inseq}))
120                  {
120                      $lineChanged{$inseq} = $lineChanged{$inseq}++;
120                  }
120                  else
120                  {
120                      $lineChanged{$inseq} = 1;
120                  }
120 
120                  #
120                  #  report it
120                  #
120                  my $lineNo = sprintf("%06d", $inseq);
120                  print RPT "$lineNo  : \t$inLine";
120             }
120         }
120 
120         $inseq++;
120         next;
120     }
120 
120     if ($found == 0)
120     {
120         #
120         #  didn't make a substitution - report it
120         #
120         print RPT "\n***\n";
120         print RPT "Translation file error\n";
120         print RPT "Line Number $transeq (in translation file) : no match found in target file\n";
120         print RPT "$line\n";
120         print RPT "*** \n\n";
120 
120         $line =~ s/\t/|/g;
120 
120         print     "***\n";
120         print     "Translation file error\n";
120         print     "Line Number $transeq (in translation file) : no match found in target file\n";
120         print     "$line\n";
120         print     "*** \n\n";
120 
120         $TotalErrors++;
120     }
120 
120 }
120 
120 
120 #
120 #  write the output file
120 #
120 foreach my $line (@outdata)
120 {
120     print OUT $line;
120 }
120 
120 close(OUT);
120 
120 print "Finished.\n\n";
120 print "___________________\n";
120 print "Results ... \n\n";
120 print "Translation complete, see the report file for details. \n";
120 print "file: ($tranfile)\n\n";
120 
120 $count = @outdata;
120 print "Number of lines written to output file: $count \n";
120 print "file: ($outfile)\n\n";
120 
120 print "... total number of errors: $TotalErrors \n\n";
120 
120 print "... total number of changes made: $TotalChanges \n\n";
120 
120 my @LinesChanged = keys %lineChanged;
120 
120 my $ChangedLineCount = @LinesChanged;
120 
120 
120 print "... total number of lines updated in the output file: $ChangedLineCount \n\n";
#
#
121 #!/bin/ksh -ph
121 #
121 #{{SHELL_IRIX  #!/usr/bin/ksh
121 #{{SHELL_LINUX #!/bin/sh
121 #
121 #+++++++++++++++++++++++++++
121 #                          |
121 #   UNIX Shell script.     |
121 #                          |
121 #+++++++++++++++++++++++++++
121 #
121 #
121 #
#
122 $!+++++++++++++++++++++++++++++
122 $!                            |
122 $!  VMS command file (DCL).   |
122 $!                            |
122 $!+++++++++++++++++++++++++++++
122 $!
122 $!
#
145 
144 
141 
146 
142 
143 
130 XX
131 ~f~oSelect and Translate a Custom Display Definitions file 
132 
133 4
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 3
157 1
&
#
130 XY
131 ~bInput:
132 
133 4
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 1
157 1
&
#
130 IN
131    Custom Display File
132 
133 14
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 4
157 1
&
#
130 TF
131    Translation File
132 
133 14
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 4
157 1
&
#
130 XZ
131 ~bOutput:
132 
133 4
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 1
157 1
&
#
130 OU
131    Translated File
132 
133 22
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 4
157 1
&
#
130 RF
131    Report File
132 
133 22
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 4
157 1
&
#
@
#
100 Translate include files
102 Translations
#
101 Created 2013-02-20 07:32:20 by SWiM
#
#
124 /*****************************/
124 /*                           */
124 /* CL Program                */
124 /*                           */
124 /*****************************/
124 
#
#
120 #++++++++++++++++++++++++++++++++++
120 #                                 |
120 #   Windows NT script (PERL).     |
120 #                                 |
120 #++++++++++++++++++++++++++++++++++
120 #
120 #
120 
120 use strict;
120 
120 use Sysgem;
120 
120 use Time::localtime;
120 
120 #
120 #   Create a timestamp.
120 #
120 my $tm      = localtime;
120 my $TimeNow = sprintf("%04d-%02d-%02d %02d:%02d:%02d",
120                       ($tm->year) + 1900,
120                       ($tm->mon)  + 1,
120                       ($tm->mday),
120                       $tm->hour,
120                       $tm->min,
120                       $tm->sec);
120 
120 my $FileExt = sprintf("_%04d-%02d-%02d_%02d-%02d-%02d.txt",
120                       ($tm->year) + 1900,
120                       ($tm->mon)  + 1,
120                       ($tm->mday),
120                       $tm->hour,
120                       $tm->min,
120                       $tm->sec);
120 
120 my $infile   = $INPUT_IN;
120 my $outfile  = $INPUT_OU;
120 my $tranfile = $INPUT_TF;
120 my $rptfile  = $INPUT_RF;
120 
120 $rptfile =~ s/.txt/$FileExt/;
120 
120 my @indata   = ();
120 my @outdata  = ();
120 my @trandata = ();
120 
120 my $inseq    = 0;
120 my $transeq  = 0;
120 
120 my $TotalChanges = 0;
120 my $TotalErrors  = 0;
120 
120 my %lineChanged = ();
120 
120 print "\n___________________\n";
120 print "Initialising ... \n\n";
120 
120 #
120 #  input file 
120 #
120 if ( open(IN, "< $infile") )
120 {
120     @indata = <IN>;
120 
120     close(IN);
120 }
120 else
120 {
120     print "Can't open input definitions file: $infile\n";
120     exit;
120 }
120 
120 
120 #
120 #  and make an exact copy as the initial version of the output file
120 #
120 if ( open(IN, "< $infile") )
120 {
120     @outdata = <IN>;
120 
120     close(IN);
120 }
120 else
120 {
120     print "Can't open input definitions file: $infile\n";
120     exit;
120 }
120 
120 #
120 #  transalation file 
120 #
120 if ( open(TRAN, "< $tranfile") )
120 {
120     @trandata = <TRAN>;
120 
120     close(TRAN);
120 }
120 else
120 {
120     print "Can't open translation file: $tranfile\n";
120     exit;
120 }
120 
120 #
120 #  output file 
120 #
120 if ( ! open(OUT, "> $outfile") )
120 {
120     print "Can't open translated output file: $outfile\n";
120     exit;
120 }
120 
120 #
120 #  report file 
120 #
120 if ( ! open(RPT, "> $rptfile") )
120 {
120     print "Can't open report file: $rptfile\n";
120     exit;
120 }
120 
120 print RPT "Translation Report - $TimeNow\n";
120 print RPT "________________________________________\n\n";
120 
120 print RPT "Input File  ........: $infile\n";
120 print RPT "Output File ........: $outfile\n";
120 print RPT "Translation File ...: $tranfile\n\n";
120 
120 
120 print RPT "Changed Lines: \n\n";
120 
120 print RPT "Line    : \tNew Text \n\n";
120 
120 #
120 #  For each line in the translation file - scan the complete custom file and make global replacements
120 #
120 my $count = @indata;
120 
120 print "Reading input file ($count lines)\n";
120 print "file: ($infile)\n\n";
120 
120 $count = @trandata;
120 
120 print "Reading translation file ($count lines)\n";
120 print "file: ($tranfile)\n\n";
120 
120 print "___________________\n";
120 print "starting to translate ...\n\n";
120 
120 foreach my $line (@trandata)
120 {
120     $transeq++;
120 
120     chomp $line;
120 
120     $line = Sysgem::TrimLeft($line);
120 
120     my @parts = split("\t", $line);
120 
120     if (substr($line, 0, 1) eq "#" || $line eq "")
120     {
120         next;
120     }
120 
120     my $sect = @parts;
120 
120     if ($sect != 3)
120     {
120         print "\@{{B Invalid Translation file - line: $transeq\n";
120         print "\@{{T Invalid Translation file - line: $transeq\n";
120         print "\@{{T \n";
120 
120         $sect--;
120 
120         print "\@{{T Number of tabs in line = $sect\n";
120         print "\@{{T \n";
120         print "\@{{T The line must have exactly two tabs.\n";
120         print "\@{{T \n";
120         print "\@{{T (line code  <tab>  original text  <tab>  translated text)\n";
120         print "\@{{T \n";
120         print "\@{{T $line \n";
120         print "\@{{T \n";
120         print "\@{{DE\n";
120 
120         print "*** ERROR ***";
120         print "$line\n";
120 
120         exit;
120     }
120 
120     my $len = length($parts[0]);
120     if ($len != 4)
120     {
120         print "\@{{B Invalid Translation file - line: $transeq\n";
120         print "\@{{T Invalid Translation file - line: $transeq\n";
120         print "\@{{T \n";
120 
120         $sect--;
120 
120         print "\@{{T Number of character in first field (line code) = $len\n";
120         print "\@{{T \n";
120         print "\@{{T The field must have exactly four characters - e.g. \"101 \"\n";
120         print "\@{{T \n";
120         print "\@{{T $line \n";
120         print "\@{{T \n";
120         print "\@{{DE\n";
120 
120         print "*** ERROR ***";
120         print "$line\n";
120 
120         exit;
120 
120     }
120 
120     #
120     #  escape special characters
120     #
120     $parts[1] =~ s/\\/\\\\/g;
120     $parts[1] =~ s/\"/\\\"/g;
120     $parts[1] =~ s/\@/\\\@/g;
120     $parts[1] =~ s/\$/\\\$/g;
120     $parts[1] =~ s/\%/\\\%/g;
120 
120     $inseq  = 0;
120     my $found = 0;
120 
120     foreach my $inLine (@indata)
120     {
120 
120         if (substr($inLine, 0, 4) eq $parts[0])
120         {
120             # 
120             # we have have a match
120             #
120             if ($inLine =~ m/$parts[1]/)
120             {
120                  #
120                  #  substitute the string
120                  #
120                  $found++;
120 
120                  $inLine =~ s/$parts[1]/$parts[2]/;
120                  $outdata[$inseq] = $inLine;
120 
120                  #
120                  #  increment total number of changes made
120                  #
120                  $TotalChanges++;
120 
120                  #
120                  #  note which line changed
120                  #
120                  if (exists($lineChanged{$inseq}))
120                  {
120                      $lineChanged{$inseq} = $lineChanged{$inseq}++;
120                  }
120                  else
120                  {
120                      $lineChanged{$inseq} = 1;
120                  }
120 
120                  #
120                  #  report it
120                  #
120                  my $lineNo = sprintf("%06d", $inseq);
120                  print RPT "$lineNo  : \t$inLine";
120             }
120         }
120 
120         $inseq++;
120         next;
120     }
120 
120     if ($found == 0)
120     {
120         #
120         #  didn't make a substitution - report it
120         #
120         print RPT "\n***\n";
120         print RPT "Translation file error\n";
120         print RPT "Line Number $transeq (in translation file) : no match found in target file\n";
120         print RPT "$line\n";
120         print RPT "*** \n\n";
120 
120         $line =~ s/\t/|/g;
120 
120         print     "***\n";
120         print     "Translation file error\n";
120         print     "Line Number $transeq (in translation file) : no match found in target file\n";
120         print     "$line\n";
120         print     "*** \n\n";
120 
120         $TotalErrors++;
120     }
120 
120 }
120 
120 
120 #
120 #  write the output file
120 #
120 foreach my $line (@outdata)
120 {
120     print OUT $line;
120 }
120 
120 close(OUT);
120 
120 print "Finished.\n\n";
120 print "___________________\n";
120 print "Results ... \n\n";
120 print "Translation complete, see the report file for details. \n";
120 print "file: ($tranfile)\n\n";
120 
120 $count = @outdata;
120 print "Number of lines written to output file: $count \n";
120 print "file: ($outfile)\n\n";
120 
120 print "... total number of errors: $TotalErrors \n\n";
120 
120 print "... total number of changes made: $TotalChanges \n\n";
120 
120 my @LinesChanged = keys %lineChanged;
120 
120 my $ChangedLineCount = @LinesChanged;
120 
120 
120 print "... total number of lines updated in the output file: $ChangedLineCount \n\n";
#
#
121 #!/bin/ksh -ph
121 #
121 #{{SHELL_IRIX  #!/usr/bin/ksh
121 #{{SHELL_LINUX #!/bin/sh
121 #
121 #+++++++++++++++++++++++++++
121 #                          |
121 #   UNIX Shell script.     |
121 #                          |
121 #+++++++++++++++++++++++++++
121 #
121 #
121 #
#
122 $!+++++++++++++++++++++++++++++
122 $!                            |
122 $!  VMS command file (DCL).   |
122 $!                            |
122 $!+++++++++++++++++++++++++++++
122 $!
122 $!
#
145 
144 
141 
146 
142 
143 
130 XX
131 ~f~oSelect and Translate a File Definitions file 
132 
133 4
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 3
157 1
&
#
130 XY
131 ~bInput:
132 
133 4
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 1
157 1
&
#
130 IN
131    Include File
132 
133 14
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 4
157 1
&
#
130 TF
131    Translation File
132 
133 14
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 4
157 1
&
#
130 XZ
131 ~bOutput:
132 
133 4
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 1
157 1
&
#
130 OU
131    Translated File
132 
133 22
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 4
157 1
&
#
130 RF
131    Report File
132 
133 22
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 4
157 1
&
#
@
#
100 Translate user tokens
102 Translations
#
101 Created 2013-02-20 07:32:20 by SWiM
#
#
124 /*****************************/
124 /*                           */
124 /* CL Program                */
124 /*                           */
124 /*****************************/
124 
#
#
120 #++++++++++++++++++++++++++++++++++
120 #                                 |
120 #   Windows NT script (PERL).     |
120 #                                 |
120 #++++++++++++++++++++++++++++++++++
120 #
120 #
120 
120 use strict;
120 
120 use Sysgem;
120 
120 use Time::localtime;
120 
120 #
120 #   Create a timestamp.
120 #
120 my $tm      = localtime;
120 my $TimeNow = sprintf("%04d-%02d-%02d %02d:%02d:%02d",
120                       ($tm->year) + 1900,
120                       ($tm->mon)  + 1,
120                       ($tm->mday),
120                       $tm->hour,
120                       $tm->min,
120                       $tm->sec);
120 
120 my $FileExt = sprintf("_%04d-%02d-%02d_%02d-%02d-%02d.txt",
120                       ($tm->year) + 1900,
120                       ($tm->mon)  + 1,
120                       ($tm->mday),
120                       $tm->hour,
120                       $tm->min,
120                       $tm->sec);
120 
120 my $infile   = $INPUT_IN;
120 my $outfile  = $INPUT_OU;
120 my $tranfile = $INPUT_TF;
120 my $rptfile  = $INPUT_RF;
120 
120 $rptfile =~ s/.txt/$FileExt/;
120 
120 my @indata   = ();
120 my @outdata  = ();
120 my @trandata = ();
120 
120 my $inseq    = 0;
120 my $transeq  = 0;
120 
120 my $TotalChanges = 0;
120 my $TotalErrors  = 0;
120 
120 my %lineChanged = ();
120 
120 print "\n___________________\n";
120 print "Initialising ... \n\n";
120 
120 #
120 #  input file 
120 #
120 if ( open(IN, "< $infile") )
120 {
120     @indata = <IN>;
120 
120     close(IN);
120 }
120 else
120 {
120     print "Can't open input definitions file: $infile\n";
120     exit;
120 }
120 
120 
120 #
120 #  and make an exact copy as the initial version of the output file
120 #
120 if ( open(IN, "< $infile") )
120 {
120     @outdata = <IN>;
120 
120     close(IN);
120 }
120 else
120 {
120     print "Can't open input definitions file: $infile\n";
120     exit;
120 }
120 
120 #
120 #  transalation file 
120 #
120 if ( open(TRAN, "< $tranfile") )
120 {
120     @trandata = <TRAN>;
120 
120     close(TRAN);
120 }
120 else
120 {
120     print "Can't open translation file: $tranfile\n";
120     exit;
120 }
120 
120 #
120 #  output file 
120 #
120 if ( ! open(OUT, "> $outfile") )
120 {
120     print "Can't open translated output file: $outfile\n";
120     exit;
120 }
120 
120 #
120 #  report file 
120 #
120 if ( ! open(RPT, "> $rptfile") )
120 {
120     print "Can't open report file: $rptfile\n";
120     exit;
120 }
120 
120 print RPT "Translation Report - $TimeNow\n";
120 print RPT "________________________________________\n\n";
120 
120 print RPT "Input File  ........: $infile\n";
120 print RPT "Output File ........: $outfile\n";
120 print RPT "Translation File ...: $tranfile\n\n";
120 
120 
120 print RPT "Changed Lines: \n\n";
120 
120 print RPT "Line    : \tNew Text \n\n";
120 
120 #
120 #  For each line in the translation file - scan the complete custom file and make global replacements
120 #
120 my $count = @indata;
120 
120 print "Reading input file ($count lines)\n";
120 print "file: ($infile)\n\n";
120 
120 $count = @trandata;
120 
120 print "Reading translation file ($count lines)\n";
120 print "file: ($tranfile)\n\n";
120 
120 print "___________________\n";
120 print "starting to translate ...\n\n";
120 
120 foreach my $line (@trandata)
120 {
120     $transeq++;
120 
120     chomp $line;
120 
120     $line = Sysgem::TrimLeft($line);
120 
120     my @parts = split("\t", $line);
120 
120     if (substr($line, 0, 1) eq "#" || $line eq "")
120     {
120         next;
120     }
120 
120     my $sect = @parts;
120 
120     if ($sect != 3)
120     {
120         print "\@{{B Invalid Translation file - line: $transeq\n";
120         print "\@{{T Invalid Translation file - line: $transeq\n";
120         print "\@{{T \n";
120 
120         $sect--;
120 
120         print "\@{{T Number of tabs in line = $sect\n";
120         print "\@{{T \n";
120         print "\@{{T The line must have exactly two tabs.\n";
120         print "\@{{T \n";
120         print "\@{{T (line code  <tab>  original text  <tab>  translated text)\n";
120         print "\@{{T \n";
120         print "\@{{T $line \n";
120         print "\@{{T \n";
120         print "\@{{DE\n";
120 
120         print "*** ERROR ***";
120         print "$line\n";
120 
120         exit;
120     }
120 
120     my $len = length($parts[0]);
120     if ($len != 4)
120     {
120         print "\@{{B Invalid Translation file - line: $transeq\n";
120         print "\@{{T Invalid Translation file - line: $transeq\n";
120         print "\@{{T \n";
120 
120         $sect--;
120 
120         print "\@{{T Number of character in first field (line code) = $len\n";
120         print "\@{{T \n";
120         print "\@{{T The field must have exactly four characters - e.g. \"101 \"\n";
120         print "\@{{T \n";
120         print "\@{{T $line \n";
120         print "\@{{T \n";
120         print "\@{{DE\n";
120 
120         print "*** ERROR ***";
120         print "$line\n";
120 
120         exit;
120 
120     }
120 
120     #
120     #  escape special characters
120     #
120     $parts[1] =~ s/\\/\\\\/g;
120     $parts[1] =~ s/\"/\\\"/g;
120     $parts[1] =~ s/\@/\\\@/g;
120     $parts[1] =~ s/\$/\\\$/g;
120     $parts[1] =~ s/\%/\\\%/g;
120 
120     $inseq  = 0;
120     my $found = 0;
120 
120     foreach my $inLine (@indata)
120     {
120 
120         if (substr($inLine, 0, 4) eq $parts[0])
120         {
120             # 
120             # we have have a match
120             #
120             if ($inLine =~ m/$parts[1]/)
120             {
120                  #
120                  #  substitute the string
120                  #
120                  $found++;
120 
120                  $inLine =~ s/$parts[1]/$parts[2]/;
120                  $outdata[$inseq] = $inLine;
120 
120                  #
120                  #  increment total number of changes made
120                  #
120                  $TotalChanges++;
120 
120                  #
120                  #  note which line changed
120                  #
120                  if (exists($lineChanged{$inseq}))
120                  {
120                      $lineChanged{$inseq} = $lineChanged{$inseq}++;
120                  }
120                  else
120                  {
120                      $lineChanged{$inseq} = 1;
120                  }
120 
120                  #
120                  #  report it
120                  #
120                  my $lineNo = sprintf("%06d", $inseq);
120                  print RPT "$lineNo  : \t$inLine";
120             }
120         }
120 
120         $inseq++;
120         next;
120     }
120 
120     if ($found == 0)
120     {
120         #
120         #  didn't make a substitution - report it
120         #
120         print RPT "\n***\n";
120         print RPT "Translation file error\n";
120         print RPT "Line Number $transeq (in translation file) : no match found in target file\n";
120         print RPT "$line\n";
120         print RPT "*** \n\n";
120 
120         $line =~ s/\t/|/g;
120 
120         print     "***\n";
120         print     "Translation file error\n";
120         print     "Line Number $transeq (in translation file) : no match found in target file\n";
120         print     "$line\n";
120         print     "*** \n\n";
120 
120         $TotalErrors++;
120     }
120 
120 }
120 
120 
120 #
120 #  write the output file
120 #
120 foreach my $line (@outdata)
120 {
120     print OUT $line;
120 }
120 
120 close(OUT);
120 
120 print "Finished.\n\n";
120 print "___________________\n";
120 print "Results ... \n\n";
120 print "Translation complete, see the report file for details. \n";
120 print "file: ($tranfile)\n\n";
120 
120 $count = @outdata;
120 print "Number of lines written to output file: $count \n";
120 print "file: ($outfile)\n\n";
120 
120 print "... total number of errors: $TotalErrors \n\n";
120 
120 print "... total number of changes made: $TotalChanges \n\n";
120 
120 my @LinesChanged = keys %lineChanged;
120 
120 my $ChangedLineCount = @LinesChanged;
120 
120 
120 print "... total number of lines updated in the output file: $ChangedLineCount \n\n";
#
#
121 #!/bin/ksh -ph
121 #
121 #{{SHELL_IRIX  #!/usr/bin/ksh
121 #{{SHELL_LINUX #!/bin/sh
121 #
121 #+++++++++++++++++++++++++++
121 #                          |
121 #   UNIX Shell script.     |
121 #                          |
121 #+++++++++++++++++++++++++++
121 #
121 #
121 #
#
122 $!+++++++++++++++++++++++++++++
122 $!                            |
122 $!  VMS command file (DCL).   |
122 $!                            |
122 $!+++++++++++++++++++++++++++++
122 $!
122 $!
#
145 
144 
141 
146 
142 
143 
130 XX
131 ~f~oSelect and Translate a User Tokens file 
132 
133 4
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 4
157 1
&
#
130 XY
131 ~bInput:
132 
133 4
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 4
157 1
&
#
130 IN
131    Token File
132 
133 14
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 4
157 1
&
#
130 TF
131    Translation File
132 
133 14
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 4
157 1
&
#
130 XZ
131 ~bOutput:
132 
133 4
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 1
157 1
&
#
130 OU
131    Translated File
132 
133 22
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 4
157 1
&
#
130 RF
131    Report File
132 
133 22
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 4
157 1
&
#
130 XW
131 
132 
133 4
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 4
157 1
&
#
130 XU
131 *** Take Care: - only translate the "Use XXXXXX Tool" token  ***
132 
133 4
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 4
157 1
&
#
130 XV
131 
132 
133 4
134 
135 0
136 
137 
138 16777215
139 
150 
151 000  
152 
153 0
154 0
156 1
157 1
&
#
@
#
#
#   License Information.
#
#{{PRODUCT:Tasks
#{{CREATED_BY:Sysgem AG,Zurich,8008,Switzerland
#
#   Checksum.
#
#{{CHECKSUM:0771-9D4C-0B12-D376-1F81-B839-C87E-151E